<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Dotnet2-web 后台管理系统</title>

<!--[if lt IE 9]>
<script src="js/html5.js"></script>
<![endif]-->
<%@ include file="/jsp/common/commonJs.jsp"%>
</head>
<body>
<!--header-->
<%@ include file="/jsp/top.jsp"%>
<!--header-->
<!--aside nav-->
<%@ include file="/jsp/left.jsp"%>
<!--aside nav  -->
<section class="rt_wrap content mCustomScrollbar">
 <div class="rt_content">
<form id="add" method="post">
 	<section class="rt_wrap content mCustomScrollbar" style="margin-top:10px;">
      <h2><strong style="color:grey;">分列内容布局</strong></h2>
      <ul class="ulColumn2">
      
       <li>
        <span class="item_name" style="width:120px;">产品名称：</span>
        <input type="text" name="productName" class="textbox textbox_295" datatype="s2-9" errormsg="产品名称至少2个字符,最多9个字符！"  placeholder="产品名称至少2个字符,最多9个字符！"/>
       <span class="Validform_checktip"></span>
       </li>
       
       <li>
        <span class="item_name" style="width:120px;">产品分类：</span>
        <select class="select" name="productType" datatype="*" errormsg="产品分类不能为空！">
	         <option value="">请选择</option>
	         <option value="1">基本产品</option>
	         <option value="2">高级产品</option>
	         <option value="3">定制产品</option>
        </select>
       </li>
       
       <li>
        <span class="item_name" style="width:120px;">所属城市：</span>
        <select class="select" name="cityName">
        	<c:forEach items="${list}" var="city">
        		<option value="${city.cityName}">${city.cityName}</option>
        	</c:forEach>
        </select>
       </li>
      
       <li>
        <span class="item_name" style="width:120px;">产品描述：</span>
        <textarea id="productDes" name="productDes" placeholder="产品描述至少10个字符,最多100个字符！" class="textarea" datatype="*" errormsg="产品描述至少10个字符,最多100个字符！" style="width:400px;height:50px;"></textarea>
       </li>
       
        <li>
        <span class="item_name" style="width:120px;">产品详情页展示：</span>
        <textarea id="productDetail" placeholder="产品描述至少10个字符,最多100个字符！" class="textarea"  style="width:100%;height:50px;"></textarea>
       </li>
        
		<li>
        <span class="item_name" style="width:120px;">产品图片：</span>
        <label class="uploadImg">
         <input type="file" name="file" onchange="uploadImg('add','showimg','productImgId','${ip}')"/>
         <input type="hidden" name="productImageUrl" id="productImgId" />
         <span ><img id="showimg"></span>
        </label>
       </li>
       
       <li>
        <span class="item_name" style="width:120px;">产品拓扑图：</span>
        <label class="uploadImg">
         <input type="file" name="file" onchange="uploadImg('add','proshowimg','productTuopuId','${ip}')"/>
         <input type="hidden" name="productTuopuImage" id="productTuopuId" />
         <span ><img id="proshowimg"></span>
        </label>
       </li>
     
       <li>
        <span class="item_name" style="width:120px;"></span>
        <input type="button" value="添加" onclick="sub()" class="link_btn"/>
       </li>
      </ul>
    </section>
</form>
</div>
</section>
</body>
<!-- 表单校验 -->
<script>

var form1=$("#add").Validform({
	tiptype:3
});


function uploadImg(formId,imgShowId,formFieldId,ip){
	//js.emptyFile(formId);
	js.upload(formId,imgShowId,formFieldId,ip);
}

//加载编辑器的容器
UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl; 
var ue = UE.getEditor('productDetail',{
	 autoHeightEnabled:false
	 ,initialFrameHeight:300
     ,initialFrameWidth:1024
});
 UE.Editor.prototype.getActionUrl = function(action) {
    if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
        return '${path}/fileUpLoad/upLoadUe.do';
    }else {
        return this._bkGetActionUrl.call(this, action);
    }
};
/* //对编辑器的操作最好在编辑器ready之后再做
ue.ready(function() {
//设置编辑器的内容  默认hello
ue.setContent('hello');
//获取html内容，返回: <p>hello</p>
var html = ue.getContent();
//获取纯文本内容，返回: hello
var txt = ue.getContentTxt();
}); */


function sub(){
	var html=ue.getContent();
	var content=ue.getContentTxt();
	//alert(html);
	//alert(content);
	if(!ue.hasContents()){
		alert("请先填写内容!");
		return;
	}
	var options = {
			url :"${path}/productinfo/addProductInfo.do",
			type : "post",
			dataType : "json",
			data:{productDetailHtml:html,productDetail:content},
			success : function(data){
				if(data.status){
					alert(data.msg);
					window.location.href="${path}/productinfo/selectAllInfo.do";
				}else{
					alert(data.msg);
				}
			}
	};
	if(form1.check()){
		$("#add").ajaxSubmit(options);
	}
}
</script>
</html>